class ScorePanel {
  score = 0
  level = 1

  scoreEle: HTMLElement
  levelEle: HTMLElement

  constructor(private maxLevel: number = 10) {
    this.scoreEle = document.getElementById("score")!
    this.levelEle = document.getElementById("level")!
  }

  // 分数增加
  addScore() {
    this.scoreEle.innerText = `${++this.score}`

    if (this.score % 10 === 0) {
      this.levelUp()
    }
  }

  // 等级提升
  levelUp() {
    if (this.level < this.maxLevel) {
      this.levelEle.innerText = `${++this.level}`
    }
  }
}

export default ScorePanel
